from mcp import ClientSession, StdioServerParameters, types
import asyncio
import os

# AnyUrl用于资源URL的类型校验
from pydantic import AnyUrl

from mcp.client.stdio import stdio_client


async def main() -> None:
    base_dir = os.path.dirname(os.path.abspath(__file__))
    server_path = os.path.join(base_dir, "server.py")
    server_params = StdioServerParameters(command="python", args=[server_path], env={})
    async with stdio_client(server_params) as (read, write):
        async with ClientSession(read, write) as session:
            await session.initialize()


if __name__ == "__main__":
    asyncio.run(main())
